package com.fh.service.contract.cuser;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.fh.dao.DaoSupport;
import com.fh.entity.Page;
import com.fh.util.PageData;


@Service("cuserService")
public class CUserService {

	@Resource(name = "daoSupport")
	private DaoSupport dao;

	private final String ns  = "CUserMapper.";
	
	/*
	* 新增
	*/
	public void save(PageData pd)throws Exception{
		dao.save(ns + "save", pd);
	}
	
	/*
	* 删除
	*/
	public void delete(PageData pd)throws Exception{
		dao.delete(ns + "delete", pd);
	}
	
	/*
	* 修改
	*/
	public void edit(PageData pd)throws Exception{
		dao.update(ns +"edit", pd);
	}
	
	/*
	*列表
	*/
	public List<PageData> list(Page page)throws Exception{
		return (List<PageData>)dao.findForList(ns + "datalistPage", page);
	}
	
	/*
	*列表(全部)
	*/
	public List<PageData> listAll(PageData pd)throws Exception{
		return (List<PageData>)dao.findForList(ns + "listAll", pd);
	}
	
	/*
	* 通过id获取数据
	*/
	public PageData findById(PageData pd)throws Exception{
		return (PageData)dao.findForObject(ns + "findById", pd);
	}
	
	/*
	* 批量删除
	*/
	public void deleteAll(String[] ArrayDATA_IDS)throws Exception{
		dao.delete(ns + "deleteAll", ArrayDATA_IDS);
	}

	/**
	 * 根据 open_id 查看用户信息
	 * @param pd
	 * @return
	 */
    public PageData findByOpenId(PageData pd) throws Exception {
		return (PageData) dao.findForObject(ns + "findByOpenId" , pd);
    }
	/**
	 * 根据 open_id 查看是否有绑定的合同信息
	 * @param pd
	 * @return
	 */
	public List<PageData> findByOpenId_reg(PageData pd) throws Exception {
		return (List<PageData>) dao.findForList("CUserMapper.findByOpenId_reg" , pd);
	}

	/*
	 * 新增微信公众号openid和 binding_state 默认不开启
	 */
	public void save_reg_user(PageData pd)throws Exception{
		dao.save("CUserMapper.save_reg_user", pd);
	}
}

